﻿using System;

using OctoOS.UI;
using OctoOS;

public partial class __admin_deleteCategory : OOSPage
{
	class PathInfo
	{
		[PathInfoMember(0)]
		[RangeValidator(1, Int64.MaxValue)]
		[IntegerBase(64)]
		internal long ID = 0;
	}

	PathInfo _pathInfo;

	protected void Page_Init(object sender, EventArgs e)
	{
		OOSRequest.Current.EnsureModerator();
		_pathInfo = EnablePathInfo<PathInfo>();
	}
	
    protected void Page_Load(object sender, EventArgs e)
    {
		var category = AppUtil.GetCategory(OOSRequest.Current, _pathInfo.ID);
		PageTitle = Resources.Main.deleteCategory_Title;

		delete.SetContent(String.Format(Resources.Main.deleteCategory_Question, category.Title));
		delete.AddSubmit(Resources.Main.shared_Yes, yesDelete);
		delete.AddCancel(Resources.Main.shared_No, Urls.Admin.GetDefault());
    }

	protected void yesDelete(object sender, EventArgs e)
	{
		ApiService.DeleteCategory(OOSRequest.Current, _pathInfo.ID);
		AppUtil.UpdateCategoriesList(OOSRequest.Current);
		Response.Redirect(Urls.Admin.GetDefault());
	}
}